<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class m_login extends CI_Model {


	public function cekUserLogin($data)
	{
		$cek['id_user'] 	= mysql_real_escape_string($data['id_user']);
		$cek['password'] 	= md5(mysql_real_escape_string($data['password']));
		$q_cek_login = $this->db->get_where('admin', $cek);
		if(count($q_cek_login->result())>0)
		{
			foreach($q_cek_login->result() as $qad)
			{
				$sess_data['logged_in'] = 'yaSudahMasuk';
				$sess_data['nama'] = $qad->nm_lengkap;
				$sess_data['kode_user'] = $qad->no_user;
				$sess_data['username'] = $qad->id_user;
				$sess_data['level'] = $qad->level;
				$this->session->set_userdata($sess_data);
			}
			redirect("home");
		}
		else
		{
			$this->session->set_flashdata("result_login",'Login Gagal');
			redirect("login");
		}

	}
}

